﻿using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;

namespace YFurion.Utils
{
    public interface IDFSManager
    {
        /// <summary>
        /// 异步上传图片
        /// </summary>
        /// <param name="file">表单文件</param>
        /// <param name="maxSize">图片最大字节</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>成功图片名</returns>
        Task<string> UploadImageAsync(IFormFile file, int maxSize, CancellationToken cancellationToken = default);

        /// <summary>
        /// 异步上传视频
        /// </summary>
        /// <param name="file">表单文件</param>
        /// <param name="maxSize">视频最大字节</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>成功视频名</returns>
        Task<string> UploadVideoAsync(IFormFile file, int maxSize, CancellationToken cancellationToken = default);

        /// <summary>
        /// 异步上传附件
        /// </summary>
        /// <param name="file">表单文件</param>
        /// <param name="exts">附件后缀数组</param>
        /// <param name="maxSize">附件最大字节</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>成功附件名</returns>
        Task<(string, object)> UploadAttachmentAsync(IFormFile file, string[] exts, int maxSize, CancellationToken cancellationToken = default);

        /// <summary>
        /// 移除图片
        /// </summary>
        /// <param name="key">图片名</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task RemoveImageAsync(string key, CancellationToken cancellationToken = default);

        /// <summary>
        /// 移除视频
        /// </summary>
        /// <param name="key">视频名</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task RemoveVideoAsync(string key, CancellationToken cancellationToken = default);

        /// <summary>
        /// 移除附件
        /// </summary>
        /// <param name="key">附件名</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task RemoveAttachmentAsync(string key, CancellationToken cancellationToken = default);

        /// <summary>
        /// 分片下载
        /// </summary>
        /// <param name="key"></param>
        /// <param name="offset"></param>
        /// <param name="length"></param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<byte[]> DownloadFileAsync(string key, long offset, long length, CancellationToken cancellationToken = default);
    }
}
